package testHutools.testClassUtil;

import cn.hutool.core.util.ClassUtil;

/**
 * @author keyer
 * @Description : 描述
 * Created by cyd on 2021-08-05 08:32:57
 */
public class Test01 {
    public static void main(String[] args) {
        TestObject02 testObject = new <String>TestObject02();
        testObject.doGet("hello");
        System.out.println("-------只有通过类的继承，才能给泛型类传入泛型参数----------");
        TestObject<String> object = new TestObject<>();
        object.doGet("world");
    }
}

class TestObject<T>{
    T str;

    public void doGet(T t){
        str=t;
        Class<?> aClass = ClassUtil.getTypeArgument(this.getClass(),0);
        System.out.println(aClass);
        System.out.println(str);
    }
}

/**
 * 只有通过类的继承，才能给泛型类传入泛型参数
 */
class TestObject02 extends TestObject<String>{
}
